package web.handle;

import java.util.List;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import ejb.dao.ForecastDAO;
import ejb.entity.City;
import ejb.entity.Forecast;
import ejb.manager.CityManager;
import ejb.manager.UserManager;

@ManagedBean
public class ForecastBean {
	@EJB
	private ForecastDAO forecastdao;
	@EJB
	private CityManager cityManager;
	@EJB
	private UserManager userManager;
	@ManagedProperty(value="#{currentUserBean}")
	private CurrentUserBean currentUserBean;
	
	private List<Forecast> forecasts;
	private List<City> cities;
	private boolean oneDayForecastAllCities;
	
	public ForecastBean(){}

	public List<Forecast> getForecasts() {
		this.forecasts = forecastdao.findAll();
		return forecasts;
	}

	public void setForecasts(List<Forecast> forecasts) {
		this.forecasts = forecasts;
	}

	public List<City> getCities() {
		this.cities = cityManager.getAllCities();
		return cities;
	}

	public void setCities(List<City> cities) {
		this.cities = cities;
	}

	public boolean isOneDayForecastAllCities() {
		this.oneDayForecastAllCities = userManager.getUserByLogin(currentUserBean.getUsername()).isForecast();
		return oneDayForecastAllCities;
	}

	public void setOneDayForecastAllCities(boolean oneDayForecastAllCities) {
		this.oneDayForecastAllCities = oneDayForecastAllCities;
	}

	public CurrentUserBean getCurrentUserBean() {
		return currentUserBean;
	}

	public void setCurrentUserBean(CurrentUserBean currentUserBean) {
		this.currentUserBean = currentUserBean;
	}
	
	

}
